home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Textfiles / zines / hir / hir3 Folder.sit / hir3 Folder / HIR3-5.TXT < prev    next >
Text File  |  1997-12-29  |  11KB  |  210 lines

  1. *-<<{([<{([<{([<{([<{([<{([<{([<{([ H i R ])}>])}>])}>])}>])}>])}>])}>])}>>-*
  2. |    Fun With UNIX I, The First of a series dealing with neat UNIX tricks   |
  3. *-<<{([<{([<{([<{([<{([<{([<{([<{([ H i R ])}>])}>])}>])}>])}>])}>])}>])}>>-*
  4.                                    By Axon
  5.  
  6. This is the first article in a series of god knows how many that will be
  7. dealing with some fun, but usually harmless (and always just pure evil)
  8. tricks that can be performed under various flavors of the UNIX operating
  9. system.  These tricks may not work on all flavors, and may not even work
  10. the same with 2 different machines running the same operating system. It
  11. has a lot to do with how the administrator has configured things. Enough
  12. with the small talk, I think it's time to go out and have fun with UNIX!
  13.  
  14. This Article, of course assumes that you have a shell account on a unix
  15. box, somewhere in the world.  It's also nice if many other people have
  16. accounts on that box, too, otherwise some of these unix fun tricks wont
  17. seem very fun, because you'll have no one to screw with or spy on.
  18.  
  19. Compatability note: I really do not know what flavors these work on.  I tested
  20. and discovered these fun tricks on an IBM (Incontinent Bowel Movement?)
  21. RS/6000 Running AiX 4.  The last trick will work on any system on which users
  22. either by default have terminal writeability enabled, or can turn it on. (some
  23. systems have it set up so users can't turn their writeability on (or can't do
  24. it very easily.)) In theory, the second trick should work on almost ANY unix
  25. machine, unless the admin has the audacity to disallow execution of things
  26. such as chmod or vi.  
  27.  
  28. Trick #1: Read other people's sent-mail.
  29.  
  30. This can be a fun trick.  It relies on the fact that the system admin guy
  31. has NO clue what he's doing.  Actually, this little nasty has been overlooked
  32. on many a system, even a few that i have access to, and I know there are more
  33. of them out there.
  34.  
  35. Pine, a wonderful text mode e-mail program that is still widely used,
  36. likes to keep things in "folders".  When a user writes an e-mail, a copy is
  37. sent to the recipient of the e-mail, and a copy is stored in the "sent-mail"
  38. folder under pine.  Typically, this "folder" is in the /mail subdirectory
  39. under the user's home directory.  There are numerous ways of finding out
  40. usernames that are on that system.  One way is just to run finger.  Jot
  41. down all the usernames you see, and keep that as a reference.  If you do
  42. this enough times, you might end up with a few hundred account names.  This
  43. is all you really need.
  44.  
  45. Another way to get account names is by trying to list all subdirectories
  46. sprouting from your parent directory.  Do the following from your home
  47. directory:
  48.  
  49. cd
  50. cd ..
  51. ls
  52.  
  53. That might list all usernames.  If the system admin knows what he's doing, it
  54. may not work.  Stick with things like the  who  and  finger  commmands to
  55. find usernames.
  56.  
  57. To read their outgoign e-mail, get to your home directory by typing  cd  alone
  58. on a line.  Type  pwd  ,which will tell you what directory you are in.  My
  59. account on my main distro site is called "axon2017".  when i type pwd from my
  60. home directory i get:
  61.  
  62. /homea/axon2017
  63.  
  64. Let's say that you want to read the sent e-mail from a person with the
  65. username "bjones".  His sent-mail folder will be in the path of:
  66.  
  67. /homea/bjones/mail
  68.  
  69. (Just a note: Chances are your system won't have a "homea" directory, it may
  70. be something like "home", or "usr", something like that possibly.)
  71.  
  72. The interesting thing about pine's e-mail "folders", is that the folder is
  73. just all the messages put directly into one file all in a row.  So, you can
  74. easily use vi, pico (blah), or cat to read the email.  Here is how i would
  75. read bjones' sent-mail:
  76.  
  77. cd                                      'gets me back to my home directory
  78. vi /homea/bjones/mail/sent-mail         'opens his sent-mail folder in vi
  79.  
  80. if you wanted to use cat, you could substitute the vi line with:
  81.  
  82. cat /homea/bjones/mail/sent-mail | more
  83.  
  84. the  | more on the end informs cat that you want the screen to pause when it
  85. scrolls one screen.  To move to the next screen, just hit the space bar, or
  86. hit q if you want to quit viewing it.
  87.  
  88. This bug is made possible because while the permissions on the mail sub-
  89. directory are usually set to where normal users can't access it, the perms
  90. on the actual files are not set to restrict viewing.  In most cases, the file
  91. can't be altered, but you can download it via FTP, or save it to your home
  92. directory.  of course this may be slightly suspicious.  If your system admin
  93. likes to view history files, that might be a problem as well.  This makes a
  94. perfect introduction to my next fun trick.
  95.  
  96.  
  97. Trick #2: Changing the past!
  98.  
  99. Changing the past?  What in the world does that mean?  Well everything you
  100. type under the shell in unix is logged (i DO so hope you know this much, but
  101. if you didn't, it's time you not only learn, but time you learn how to change
  102. what that log shows.  This really is a job for the VI editor.  Pico does not
  103. work on the history file usually.  The file is called .sh_history, in each
  104. user's home directory.  Since it starts with a dot, it will be hidden from the
  105. LS command unless you use the -a flag.  I would venture a guess that this
  106. file began as some sort of security measure, to monitor what people were doing
  107. on the system, and keeping it somewhat hidden from prying eyes.  The only
  108. problem with this is the fact that any efforts to edit it will end up being
  109. appended to the end of the log file once your editor closes the file.  Talk
  110. about "begging for attention"...that's a way to get it from your admin.
  111.  
  112. I've always thought shell scripts were useful.  A Shell script is exactly
  113. the same as a DOS Batch File.  Each command you want to execute in the script
  114. is put on its own line.  When the script is executed, it will run each line
  115. sequentially.  We'll make a simple shell script in order to edit our history
  116. file.  The thing is, we need to name this script the same as a normal unix
  117. command.  I chose cls, which is not really a normal unix command, but some
  118. UNIX's have a shell script that does the same thing.  CLEAR is the commmand
  119. typically used to clear a screen.  Cls might seem like a typical error, when
  120. an admin sees it in the logs.  This is the source code you need to store in
  121. the file.  Use vi, Pico, or echo >> to do this.  I just used echo >> here's
  122. my example.
  123.  
  124. source code:
  125.  
  126. #!/bin/ksh
  127. #This Script Clears The Screen
  128. vi .sh_history
  129.  
  130. This is all I did to make the file using echo >>:
  131.  
  132. echo "#!/bin/ksh" >> cls
  133. echo "#This Script Clears The Screen" >> cls
  134. echo "vi .sh_history" >> cls
  135.  
  136.  
  137. the >> redirects the results of echo out to a file, in this case CLS, adding
  138. the text to the end of the file.
  139.  
  140. If you are not very well-versed in UNiX yet, you may not realize that the
  141. script you just made has to bbe made an executable.  In DOS, if a file has
  142. a .COM, .EXE, or .BAT extension, it refers to it as executable.  In UNIX,
  143. there really are no file extensions.  A period can be used in a filename, or
  144. several periods.  You have to use the change mode command, called CHMOD to
  145. make this file executable.
  146.  
  147. chmod 700 cls
  148.  
  149. No, 700 is not some magic code for "make it executable".  The first digit is
  150. what access you have to the file, the second and third, you dont need to worry
  151. about, because those are what access other people have to your file.  We set
  152. these to 0, which means you are denying them any access.  7 makes the file
  153. readable, writeable, and executable.
  154.  
  155. Now, when you type cls, your history file will appear on screen with the vi
  156. editor.  I will NOT go over the whole vi editor command set with you, but I
  157. will tell you enough to take lines out of your .sh_history file.
  158.  
  159. When in vi, use the arrow keys to get to the line(s) you wish to take out.
  160. to delete a whole line, hit  <d> <d>  yes, that's right...hit the "D" key
  161. twice.  make sure caps and shift are turned OFF!  Poof! the line is gone.
  162. you can move to another line and use <d> <d> again and again.  To save the
  163. file hit <:> <w> <!> <enter>.  Once the file is saved, hit <:> <q> and you
  164. are back to the prompt.  Easy, huh?
  165.  
  166.  
  167. Trick #3: Let's mess with someone's terminal!
  168.  
  169. This is a little more involved, and does not work at all unless someone else
  170. is on the same system as you are, and has their terminal writeability enabled.
  171. To see who is writeable, type  "who -w"  You will see a few fields, the only
  172. ones we care about will be the login-name field, the terminal field, and the
  173. field containing only + or - symbols.  If there are any + symbols, you are in
  174. luck, for now you have someone to mess with.
  175.  
  176. If you want to just test this, then go to a computer lab or library where you
  177. can use telnet on 2 computers side by side, and log in to the same host 2
  178. times, once on either machine.  type  mesg y  at both of the unix prompts,
  179. then find out which virtual terminals you are on (using the terminal field
  180. of the who -w command) You will be interested mostly in the other one, the
  181. one that you are next to, not the one that you are sitting and typing at.
  182. once you find that virtual terminal, you are ready to go.  You will from now
  183. on refer to that virtual terminal as /dev/pts/2  or whatever it is, even
  184. though the terminal field only says pts/2, you need to refer to it with the
  185. /dev/ in front of it.  
  186.  
  187. Try clearing the other screen.  This is fairly simple.
  188.  
  189. clear > termpath
  190.  
  191. termpath will be the /dev/pts/2 or whatnot.  See, the output of any program
  192. can be sent to any other virtual terminal that is writeable.  the greater-
  193. than sign is used to REDIRECT the output.  You can run anything, and make the
  194. other screen look exactly like yours would.  Things to try: redirecting a
  195. pine session, redirecting output from various unix commands such as finger,
  196. who, and even telnet.  Another possibility if you want to annoy, use cat to
  197. read a binary file, then redirect the output to the terminal
  198. (cat /bin/ksh > /dev/pts/2).  Oh the evil deeds you can persue...
  199.  
  200. Using this little ability to annoy someone to the point where they will close
  201. their telnet connection to the host can open up other security holes, for
  202. instance with proper timing and a lot of hard work, you can capture a log-in
  203. session and snag passwords, however this is detailed in far too many cookbook
  204. hacks that are available elsewhere, and begin to stray from the informative
  205. nature of this publication, as its useage really can not be used for purposes
  206. aside from obtaining passwords and logins (cool stuff but far outside the
  207. scope that i wish to cover here)
  208.  
  209. Look for more Unix fun in future releases of HiR.
  210.